package ustc.xiaoyang.karl.doublepointer;

import java.util.Arrays;

public class DeleteDuplicatesInAnOrderedArray26 {
    public static void main(String[] args) {

        int [] nums = {1,1,2};
        System.out.println(new DeleteDuplicatesInAnOrderedArray26().removeDuplicates(nums));
    }
    public int removeDuplicates(int[] nums){
        int slow = 1;
        for (int fast = 1; fast < nums.length; fast++) {
            if(nums[fast] != nums[slow-1]){
                nums[slow++] = nums[fast];
            }
        }
        System.out.println(Arrays.toString(nums));
        return slow;

    }
}
